<?php

namespace App\Http\Controllers\Sdk;

use App\Http\Controllers\Controller;
use App\Models\Agent;

class AgentController extends Controller
{
    /**
     * 根据 ID 查询代理商信息
     * @param $phone
     * @return mixed
     */
    public function info($id)
    {
        return $this->response->array(
            Agent::query()
                ->select(['id', 'name', 'phone', 'level', 'balance', 'unextractable_balance'])
                ->findOrFail($id)
                ->toArray()
        );
    }

    /**
     * 根据手机号查询代理商信息
     * @param $phone
     * @return mixed
     */
    public function infoByPhone($phone)
    {
        return $this->response->array(
            Agent::query()
                ->where('phone', $phone)
                ->select(['id', 'name', 'phone', 'level', 'balance', 'unextractable_balance'])
                ->firstOrFail()
                ->toArray()
        );
    }
}
